package Day07;

import java.util.Scanner;

public class GirlText {
    public static void main(String[] args) {
        //定义一个数组来存储对象
        Girl[] arr = new Girl[4];

        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            Girl g = new Girl();
            System.out.println("刚问姑娘芳名？");
            g.setName(sc.next());

            System.out.println("刚问姑娘高寿？");
            g.setAge(sc.nextInt());

            System.out.println("菇凉是何类型?");
            g.setGender(sc.next());

            System.out.println("菇凉平时可有何爱好?");
            g.setHobby(sc.next());

            arr[i] = g;
        }

        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i].getAge();
        }

        int avg = sum / arr.length;

        System.out.println("女朋友的平均年龄是" + avg);

        for (int i = 0; i < arr.length; i++) {
            if(arr[i].getAge() <  avg){
                Girl g1 = arr[i];
                System.out.println(g1.getName() +", " + g1.getAge()+","
                        + g1.getGender()+ "," + g1.getHobby());
            }
        }
    }
}
